<%--
  Created by IntelliJ IDEA.
  User: 14811
  Date: 2022-3-23
  Time: 9:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="common/common.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" type="text/css" href="<%=path%>/css/newLogin.css">
  <title>旅游后台</title>
</head>
<body>
<section>
  <!-- 背景颜色 -->
  <div class="color"></div>
  <div class="color"></div>
  <div class="color"></div>
  <div class="box">
    <!-- 背景圆 -->
    <div class="circle" style="--x:0"></div>
    <div class="circle" style="--x:1"></div>
    <div class="circle" style="--x:2"></div>
    <div class="circle" style="--x:3"></div>
    <div class="circle" style="--x:4"></div>
    <!-- 登录框 -->
    <div class="container">
      <div class="form">
        <h2>登录</h2>
        <form id="form_login">
          <div class="inputBox">
            <input type="text" name="username" placeholder="姓名">

          </div>
          <div class="inputBox">
            <input type="password" name="password" placeholder="密码">

          </div>
          <div class="inputBox">
            <input type="button" onclick="user_login()" value="登录">

          </div>
          <p class="forget">忘记密码?<a href="#">
            点击这里
          </a></p>
          <p class="forget">没有账户?<a href="javascript:user_register()">
            注册
          </a></p>
        </form>
      </div>
    </div>
  </div>
</section>
</body>
</html>


<script type="text/javascript">
  function user_login() {
    $.ajax({
      url : "<%=path%>/loginController/login",
      dataType : "json",
      type : "post",
      data : $("#form_login").serialize(),
      async : true,
      success : function (data) {
        if (data == 0) {
          var myDialog = dialog({
            content : "登录成功"
          })

          myDialog.show();
          setTimeout(function(){
            myDialog.close();
            window.location.replace("<%=path%>/treeController/toTree")
          }, 2000)

        } else if (data == 1) {
          dialog_private("账号不存在")
        } else if (data == 2) {
          dialog_private("账号密码为空")
        } else if (data == 3) {
          dialog_private("账号已经被冻结")
        } else if (data == 4) {
          dialog_private("账号密码错误")
        }
      },
      error : function (e) {
        console.log(e);
        alert("系统错误")
      }
    })

  }
  function user_register() {
    location.href="register.jsp"
  }
</script>
